package com.escapeicon.bigevent.validation;

import com.escapeicon.bigevent.anno.State;
import jakarta.validation.Constraint;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

public class StateValidation implements ConstraintValidator<State,String> {

    /**
     * 验证的条件
     * @param value 待验证的数据
     * @param constraintValidatorContext
     * @return
     */
    @Override
    public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
        // 判断是否为 null
        if (value == null) {
            return false;
        }

        // 判断是否 符合要求
        if ("已发布".equals(value) || "草稿".equals(value)) {
            return true;
        }
        return false;
    }
}
